﻿<!DOCTYPE html>

<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    <meta charset="utf-8" />
    <title>摩斯密码生成器 - 在线工具 - 迷糊虫的工具箱</title>
    <link rel="shortcut icon" href="/tools/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui-v2.5.6/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="/tools/static/css/fly/global.css" />
    <link rel="stylesheet" type="text/css" href="/tools/static/css/global.css" />
    <style>
        .layui-textarea {
            height: calc(((100vh - 322px) - 193px) / 2);
            min-height: 150px;
        }
    </style>
</head>
<body>
    <div class="layui-header header header-extends" style="background-color: #24262F;">
        <div class="layui-container">
            <a class="fly-logo" href="/tools">迷糊虫的工具箱</a>
            <div class="layui-form component" lay-filter="LAY-site-header-component">

            </div>
            <ul class="layui-nav tools-nav" lay-filter="tools-nav">
            </ul>
        </div>
    </div>
    <div class="fly-extend-detail layui-card">
        <div class="layui-container">
            <div class="fly-extend-list-header">
                <h1 class="fly-extend-title layui-elip"><a>摩斯密码生成器</a><span class="layui-badge layui-bg-green layui-hide-xs">加密/解密</span></h1>
            </div>
            <p class="fly-extend-list-desc">
                基于xmorse，支持加密明文、解密密文。
            </p>
            <div class="layui-btn-container layui-extend-doc-edit">
            </div>
        </div>
    </div>
    <div class="layui-container">
        <div class="layui-form" style="margin-bottom: 15px;">
            <div class="layui-card">
                <div class="layui-card-header">明文</div>
                <div class="layui-card-body">
                    <textarea id="DeCode" class="layui-textarea" placeholder="明文"></textarea>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">密文</div>
                <div class="layui-card-body">
                    <textarea id="EnCode" class="layui-textarea" placeholder="密文"></textarea>
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-body layui-btn-container" style="padding-bottom:0px;">
                    <input type="button" class="EnCodeMorse layui-btn" value="生成摩斯密码" />
                    <input type="button" class="DeCodeMorse layui-btn layui-btn-normal" value="解密摩斯密码" />
                    <input type="button" class="Empty layui-btn layui-btn-danger" value="清空" />
                    <input type="button" class="layui-btn layui-btn-warm" data-clipboard-target="#DeCode" value="复制明文" />
                    <input type="button" class="layui-btn layui-btn-warm" data-clipboard-target="#EnCode" value="复制密文" />
                </div>
            </div>
        </div>
    </div>
    <script src="/tools/static/js/jquery/jquery.min.js"></script>
    <script src="https://www.layuicdn.com/layui-v2.5.6/layui.js"></script>
    <script src="/tools/static/js/clipboard/clipboard.min.js"></script>
    <script src="/tools/static/js/main.js"></script>
    <script src="./static/js/xmorse/xmorse.min.js"></script>
    <script>
        if (isWeiXin()) {
            $('.fly-header').hide();
        }
        layui.use(['element', 'form'], function () {
            var element = layui.element,
                form = layui.form;

            var clipboard = new ClipboardJS('.Copy');
            clipboard.on('success', function (e) {
                layer.msg("复制成功", { icon: 6 }); //需引入 layui
            });
            clipboard.on('error', function (e) {
                layer.msg("复制失败", { icon: 5 }); ////需引入 layui
            });

            $(document).on("click", ".Empty", function () {
                $("#DeCode").val('')
                $("#EnCode").val('')
            })
            $(document).on("click", ".EnCodeMorse", function () {
                var DeCode = $("#DeCode").val();
                if (DeCode) {
                    $("#EnCode").val(xmorse.encode(DeCode));
                } else {
                    layer.msg("请输入明文", { icon: 5 }); ////需引入 layui
                }
            })
            $(document).on("click", ".DeCodeMorse", function () {
                var EnCode = $("#EnCode").val();
                if (EnCode) {
                    $("#DeCode").val(xmorse.decode(EnCode));
                } else {
                    layer.msg("请输入密文", { icon: 5 }); ////需引入 layui
                }
            })
        })
        function isWeiXin() {
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.match(/WeiBo/i) == "weibo") {
                return true;
            } else if (ua.indexOf('mobile mqqbrowser') > -1) {
                return true;
            } else if (ua.indexOf('iphone') > -1 || ua.indexOf('mac') > -1) {
                if (ua.indexOf('qq') > -1) {
                    return true;
                }
            }
            return false;
        }
    </script>
</body>
</html>
